package com.holly.unit.bpmn.modular.activiti.controller;

import com.holly.unit.bpmn.activiti.ActivitiOperator;
import com.holly.unit.bpmn.activiti.pojo.ActFromRequest;
import com.holly.unit.core.pojo.response.ResponseData;
import com.holly.unit.core.pojo.response.SuccessResponseData;
import com.holly.unit.scanner.api.annotation.ApiResource;
import com.holly.unit.scanner.api.annotation.GetResource;
import com.holly.unit.scanner.api.annotation.PostResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@ApiResource(name = "流程定义表单设置")
@Api(tags = "流程定义表单设置")
public class ActFromController {

    @Resource
    private ActivitiOperator operator;

    /**
     * 添加
     * @param actFromRequest
     * @return
     */
    @ApiOperation(value = "流程定义表单设置_添加" ,notes = "流程定义表单设置_添加")
    @PostResource(name = "流程定义表单设置_添加", path = "/actFrom/addActFrom", requiredPermission = false , requiredLogin = false)
    public ResponseData addActFrom(@RequestBody @Validated(ActFromRequest.add.class) ActFromRequest actFromRequest) {
        operator.addActFrom(actFromRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     * @param actFromRequest
     * @author holly
     * @date 2022-03-21 02:44:34
     */
    @ApiOperation(value = "流程定义表单设置_编辑" ,notes = "流程定义表单设置_编辑")
    @PostResource(name = "流程定义表单设置_编辑", path = "/actFrom/editActFrom", requiredPermission = false , requiredLogin = false)
    public ResponseData editActFrom(@RequestBody @Validated(ActFromRequest.edit.class) ActFromRequest actFromRequest) {
        operator.editActFrom(actFromRequest);
        return new SuccessResponseData();
    }

    /**
     * 分页列表查询
     * @author holly
     * @date 2022-03-21 02:44:34
     */
    @ApiOperation(value = "流程定义表单设置_分页查询" ,notes = "流程定义表单设置_分页查询")
    @GetResource(name = "流程定义表单设置_分页查询", path = "/actFrom/getFromPage", requiredPermission = false , requiredLogin = false)
    public ResponseData getFromPage(ActFromRequest actFromRequest) {
        return new SuccessResponseData(operator.getFromPage(actFromRequest));
    }

    /**
     * 删除
     * @author holly
     * @date 2022-03-21 02:44:34
     */
    @ApiOperation(value = "流程定义表单设置_删除" ,notes = "流程定义表单设置_删除")
    @PostResource(name = "流程定义表单设置_删除", path = "/actFrom/delete", requiredPermission = false , requiredLogin = false)
    public ResponseData delete(@RequestBody @Validated(ActFromRequest.delete.class) ActFromRequest actFromRequest) {
        operator.editActFrom(actFromRequest);
        return new SuccessResponseData();
    }

    /**
     * 查询详情
     * @author holly
     * @date 2022-03-21 02:44:34
     */
    @ApiOperation(value = "流程定义表单设置_查询详情" ,notes = "流程定义表单设置_查询详情")
    @GetResource(name = "流程定义表单设置_查询详情", path = "/actFrom/detail", requiredPermission = false , requiredLogin = false)
    public ResponseData detail(@RequestParam(value = "id") String id) {
        return new SuccessResponseData(operator.getActFormById(id));
    }

}
